//
//  LXNavigationViewController.m
//  微博
//
//  Created by imera on 15/9/17.
//  Copyright (c) 2015年 imera. All rights reserved.
//

#import "LXNavigationViewController.h"

@interface LXNavigationViewController ()

@end

@implementation LXNavigationViewController

//第一次使用这个类会调用一次，一个类只调用一次
+(void)initialize
{
    [self setupBarButtonItem];
    
    [self setupNavBar];
}

//设置导航栏主题
+ (void)setupNavBar
{
    //设置导航栏字体
    UINavigationBar *bar = [UINavigationBar appearance];
    
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    
    textAttrs[NSForegroundColorAttributeName] = [UIColor blackColor];
    textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:20];
    
    [bar setTitleTextAttributes:textAttrs];
}

//设置导航栏按钮主题
+ (void)setupBarButtonItem
{
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    //设置导航栏按钮字体
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [UIColor orangeColor];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:16];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
    
    //设置不能点击时变灰
    NSMutableDictionary *disableTextAttrs = [NSMutableDictionary dictionary];
    disableTextAttrs[NSForegroundColorAttributeName] =  [UIColor lightGrayColor];
    [item setTitleTextAttributes:disableTextAttrs forState:UIControlStateDisabled];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //如果有两个子控制器就隐藏底部状态栏
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:animated];
}

@end
